<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="cyys" uri="http://www.cyys.com/cyystaglib"%>
<!DOCTYPE html>
<html>
<head>
  	<meta charset="utf-8">
  	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  	<title>通知公告</title>
  	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
	<!-- 文件上传 -->
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/fileUpload.css?v=${FILE_VERSION}">
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 15px;">
		<form class="layui-form" action="" style="width:80%" method="post" id="basicform">
			<input type="hidden" id="id" name="id" value="${notice.id }"/>

			<div class="layui-form-item">
				<label class="layui-form-label layui-form-required">所属机构</label>
				<div class="layui-input-inline">
					<input type="hidden" id="orgId" name="orgId" value="${notice.orgId }">
					<input type="text" id="orgName" autocomplete="off" class="layui-input" lay-verify="required"
						  value="${notice.orgName }" readonly
						   <c:if test="${roleScope!= '3'}">onclick="selectOrg()"</c:if>
					>
				</div>
				<c:if test="${roleScope!= '3'}">
					<div class="layui-input-inline">
						<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="selectOrg()">点击选择</button>
					</div>
				</c:if>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">通知类型</label>
				<div class="layui-input-inline">
					<select name="type">
						<option value="">请选择通知类型</option>
						<cyys:dict name="NOTICE_TYPE" dv="${notice.type}"/>
					</select>
				</div>
<%--				<div class="layui-form-mid layui-word-aux">提示：公告类型不够用请自行前往字典管理里加：--%>
<%--					<a class="layui-font-blue" style="text-decoration: underline;cursor: pointer;" onclick="gotoParamMng('${noticeTypeBasicId}')">类型管理</a>。--%>
<%--				</div>--%>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label layui-form-required">通知标题</label>
				<div class="layui-input-block">
					<input class="layui-input" name="title" lay-verify="required"
						   placeholder="请输入通知标题" maxlength="100" value="${notice.title}">
				</div>
			</div>
			<div class="layui-form-item" >
				<label class="layui-form-label layui-form-required">通知内容</label>
				<div class="layui-input-block">
					<textarea name="content" lay-verify="required" placeholder="请输入通知内容，500字内" class="layui-textarea" value="${notice.content}">${notice.content}</textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">附件</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="$selectFileManage(2,'attachments')">选择附件</button>
					<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;" >
						预览图<font style="color: red">(可拖拽图标进行排序,排序后请点击提交按钮)</font>：
						<ul class="layui-upload-ul" id="attachments">
							<c:if test="${not empty notice.attachments}">
								<c:forEach items='${fn:split(notice.attachments,",")}' var="item" >
									<li class="layui-upload-list" style="width:100px;">
										<input value="${item}" type="hidden" class="fileUrlInput">
										<c:set var="fileExt" value="${fn:substring(item,cyys:lastIndexOf(item, '.') + 1,item.length())}" />
										<img class="layui-upload-img" src="${FILE_WEB_PATH}${item}" onerror="this.src=getSrcByExt('${item}')">
										<div class="closeBtu" onclick="deleteFile('${item}',this,true)">
											<img src="/static/images/xbtn.png">
										</div>
									</li>
								</c:forEach>
							</c:if>
						</ul>
						<div style="clear:both;"></div>
					</blockquote>
					<input class="fileUrlsInput" value="${notice.attachments}" name="attachments" type="hidden">
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-primary layui-border-blue" lay-submit="" lay-filter="sub">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary layui-border-blue">重置</button>
					<button type="button" class="layui-btn layui-btn-primary layui-border-red" onclick="closed()">关闭</button>
				</div>
			</div>
		</form>
	</div>
	</div>
</div>
<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/common/coreInput-2.0.0.js?v=${FILE_VERSION}"></script>
<!-- 图片上传 -->
<script src="${pageContext.request.contextPath}/static/js/upload/fileUpload-2.0.0.js?v=${FILE_VERSION}"></script>
<script>
    layui.use(['form','element'], function(){
		layui.form.on('submit(sub)', function(data){
			var attachments= getMutifileUrl('#attachments');
			if(attachments==null){
				attachments= "";
			}
			data.field['attachments']= attachments;
			return saveOrUpdate($("#id").val(),"/sys/orgNotice",data);
		});
    });

    function selectOrg(){
        var url  = getContextPath() +  "/sys/org/setOrg?queryTop=false";
        layer.open({
            title : "选择所属机构",
            type: 2,
            area: ['500px', '90%'],
            anim: 2,
            content: [url, 'yes']
        });
    }

    function setOrg(id,name){
        $("#orgId").val(id);
        $("#orgName").val(name);
        layer.closeAll();
    }

</script>
</body>
</html>